package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询对应的套餐id
     * @param ids
     * @return
     */
    List<Long> getDishIdDelete(List<Long> ids);

    /**
     *新增套餐菜品关系
     * @param setmealDishes
     */
    void insertSetmeal(List<SetmealDish> setmealDishes);

    /**
     * 菜品状态修改在关系表里面查找
     * @param id
     */
    @Select("select setmeal_id from setmeal_dish where dish_id = #{dishId}")
    List<Long> getById(Long id);

    /**
     * 根据ID查询套餐
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getSetmealDish(Long id);

    /**
     * 修改前删除
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id =#{id}")
    void delete(Long id);

    /**
     * 根据套餐id查找菜品id
     * @param id
     * @return
     */
    @Select("select dish_id from setmeal_dish where setmeal_id = #{id}")
    List<Long> updateGetById(Long id);
}
